﻿package com.PlantVsZombies.constant;

import java.awt.Dimension;
import java.awt.Image;

import com.PlantVsZombies.util.ImageUtil;

public enum ZombieType {
	
	/** 举旗僵尸 */
	ZOMBIE_FLAG(0, ImageUtil.FlagZombie, "举旗僵尸", 10, 110),
	/** 普通僵尸 */
	ZOMBIE_NORMAL(1, ImageUtil.zombie, "普通僵尸", 130, 110),
	/** 圆锥帽子僵尸 */
	ZOMBIE_CONEHEAD(2, ImageUtil.ConeheadZombie, "圆锥帽子僵尸", 250, 110),
	/** 铁桶僵尸 */
	ZOMBIE_BUCKET(3, ImageUtil.bucketheadZombie, "铁桶僵尸", 10, 260),
	/** 报纸僵尸 */
	ZOMBIE_NEWSPAPER(4, ImageUtil.ConeheadZombie, "报纸僵尸", 130, 260),
	/** 足球僵尸 */
	ZOMBIE_FOOTBALL(5, ImageUtil.FootballZombieWalk, "足球僵尸", 250, 260),
	/** 撑杆跳僵尸 */
	ZOMBIE_POLEVAULTING(6, ImageUtil.PoleVaultingZombieRun, "撑杆跳僵尸", 10, 410);
	
	private Integer code;
	
	private Image image;
	
	private String name;
	
	private int x;
	
	private int y;

	ZombieType(Integer code, Image image, String name, int x, int y) {
		this.code = code;
		this.image = image;
		this.name = name;
		this.x = x;
		this.y = y;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public static Dimension getDimension() {
		int width = 300;
		int length = ZombieType.values().length;
		int height = length % 3 == 0 ? (length/3)*150 : (length/3+1)*150;
		Dimension dimension = new Dimension(width, height);
		return dimension;
	}
	
	public static ZombieType valueOfName(String name) {
		for (ZombieType z : ZombieType.values()) {
			if (z.getName().equals(name)) {
				return z;
			}
		}
		return null;
	}
}
